/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.gnp.action;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mx.gnp.dao.ProductoDAO;
import mx.gnp.entity.Producto;
import mx.gnp.service.ProductoService;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Matersys 86
 */
public class VentaAction extends org.apache.struts.action.Action {

    private static final String SUCCESS = "success";
    private static final String ERROR = "error";
    
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
             throws Exception{

        String producto = request.getParameter("producto");
        String precio= request.getParameter("precio");
        String cantidad= request.getParameter("cantidad");

        Producto p = new Producto ();
        p.setIdProducto(new Integer(producto));
        p.setPrecioVenta(new Double(precio));
        p.setCantidad(new Integer(cantidad));

        ProductoService ps = new ProductoService();
        try {
            ps.realizaVenta(p);
        } catch (SQLException ex) {
            Logger.getLogger(VentaAction.class.getName()).log(Level.SEVERE, null, ex);
        }


        return mapping.findForward(SUCCESS);
    }
}
